﻿using Ledict.ConditionExtract.Base;
using Ledict.ConditionExtract.BLL;
using Ledict.ConditionExtract.Common;
using Ledict.ConditionExtract.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using Ledict.Utility.Msg;

namespace Ledict.ConditionExtract
{
    /// <summary>
    /// 引用法规
    /// </summary>
    public partial class AboutLaw : BaseForm
    {
        #region 构造单例
        public AboutLaw()
        {
            InitializeComponent();
        }
        static AboutLaw _default;
        public static AboutLaw Default
        {
            get
            {
                if (_default == null || _default.IsDisposed)
                {
                    _default = new AboutLaw();
                }
                return _default;
            }
        }
        #endregion


        TreeDataBLL trbll = new TreeDataBLL();
        NewIDBLL newid = new NewIDBLL();
        CaseCauseBLL casecausebLL = new CaseCauseBLL();
        QuoteLawRelBLL quoteLawRelBLL = new QuoteLawRelBLL();
        //AboutRegexBLL regexbll = new AboutRegexBLL();



        //Express_SourceBLL SourceBLL = new Express_SourceBLL();
        //Ledict.Regex.BLL.Reg_InfoRegexRelationBLL unitrelation = new Reg_InfoRegexRelationBLL();
        //Ledict.Regex.BLL.Reg_RegexsBLL addreg = new Reg_RegexsBLL();
        //CaseCauseInferConditionBLL infer = new CaseCauseInferConditionBLL();
        //RegexParse.RegexParse getregex = new RegexParse.RegexParse();
        //AnalysisInferRuleBLL analysisInferRule = new AnalysisInferRuleBLL();
        //AnalysisXMLBLL analysisXML = new AnalysisXMLBLL();

        //ArgumentTypeXmlBLL argumenttypexmlbll = new ArgumentTypeXmlBLL();
        #region 共有变量
        private TreeNode clicknode = null;

        private List<TreeNode> NodeList = new List<TreeNode>();
        //private List<TreeNode> SourceNodeList = new List<TreeNode>();
        public string TypeName = "刑事";
        public string FirId = "1000";
        public string LocateNode = "";
        #endregion

        private void AboutLaw_Load(object sender, EventArgs e)
        {
            CaseCauseTree();

        }


        #region 左侧
        #region 左侧树
        ///// <summary>
        ///// 定位
        ///// </summary>
        ///// <param name="id">ID</param>
        //private void ToLocateNode(string id)
        //{
        //    string[] NotePidArr = getregex.GetParseValue("CC1509171748560001", trbll.GetAllParentNode(id)).Split(','); //去掉多余逗号 ;
        //    for (int i = 0; i < NotePidArr.Length; i++)
        //    {
        //        if (i != NotePidArr.Length - 1)
        //        {
        //            FindNode(NotePidArr[i]).Expand();
        //        }
        //        else
        //        {
        //            TreeNode node = FindNode(NotePidArr[i]);
        //            this.tVCaseCause.SelectedNode = node;
        //        }
        //    }

        //}


        #region 情形情节节点树
        /// <summary>
        /// 案由树（第一级）
        /// </summary>
        public void CaseCauseTree()
        {
            #region 初始化
            this.tVCaseCause.Nodes.Clear();
            NodeList = new List<TreeNode>();

            StacticQuery.Text = "";
            CurrNodeNum.Text = "";
            SumQuery.Text = "";
            #endregion
            DataTable dt = trbll.NodeTree_Tree("");
            DataRow[] arrayDr = dt.Select("name='" + TypeName + "案由" + "' or " + "name='" + TypeName + "程序法" + "'");
            foreach (DataRow caseTreeNodeRode in arrayDr)
            {
                TreeNode node = new TreeNode();
                node.Text = LdFormat.ObjectToString(caseTreeNodeRode[1]).Replace("刑事罪名", "实体法");
                node.Tag = caseTreeNodeRode[0];
                node.Name = LdFormat.ObjectToString(caseTreeNodeRode[2]);
                FirId = caseTreeNodeRode[0].ToString();
                if (trbll.NodeTree_Tree(node.Tag.ToString()).Rows.Count > 0)
                {
                    node.Nodes.Add(new TreeNode());
                }
                tVCaseCause.Nodes.Add(node);
                NodeList.Add(node);
            }
        }
        /// <summary>
        /// 查询节点的下级树
        /// </summary>
        /// <param name="parentNode">父节点</param>
        private void CaseCauseTreeChild(TreeNode parentNode)
        {
            string pid = parentNode.Tag.ToString();
            DataTable caseTreeNodeRode = trbll.NodeTree_Tree(pid);
            if (caseTreeNodeRode.Rows.Count == 0)
                return;
            for (int i = 0; i < caseTreeNodeRode.Rows.Count; i++)
            {
                string nodeid = caseTreeNodeRode.Rows[i]["id"].ToString();
                if (nodeid != "1410" && nodeid != "3333333" && nodeid != "CC1509101516430001" && nodeid != "CC1509141224060001" && nodeid != "27565")
                {
                    TreeNode node = new TreeNode();
                    node.Tag = caseTreeNodeRode.Rows[i]["id"].ToString();
                    node.Text = LdFormat.ObjectToString(caseTreeNodeRode.Rows[i]["name"]);

                    node.Name = LdFormat.ObjectToString(caseTreeNodeRode.Rows[i]["CC_NodeType"]);
                    if (trbll.NodeTree_Tree(node.Tag.ToString()).Rows.Count > 0)
                    {
                        node.Nodes.Add(new TreeNode());
                    }
                    parentNode.Nodes.Add(node);
                    NodeList.Add(node);

                }
            }
        }

        /// <summary>
        /// 展开节点
        /// </summary>
        /// <param name="sender">触发对象</param>
        /// <param name="e">节点</param>
        private void tVCaseCause_AfterExpand(object sender, TreeViewEventArgs e)
        {
            e.Node.Nodes.Clear();
            CaseCauseTreeChild(e.Node);
        }

        /// <summary>
        /// 点击节点
        /// </summary>
        /// <param name="sender">触发对象</param>
        /// <param name="e">节点</param>
        private void tVCaseCause_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (clicknode != null)
            {
                clicknode.ForeColor = Color.Black;
            }
            if (IsUseFul(e)) //是否有效节点
            {
                clicknode = e.Node;
                clicknode.ForeColor = Color.Red;
                GetRightValue(e);
            }
        }

        #endregion

        /// <summary>
        /// 是否有用情形
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public bool IsUseFul(TreeViewEventArgs e)
        {
            //int type;
            //try
            //{
            //    type = Convert.ToInt32(e.Node.Name.ToString());
            //}
            //catch
            //{
            //    type = 9;
            //}
            //if (type == 4 || type == 5 || type == 6 || type == 7 || type == 8 || type == 100 || type == 9 || type == 2)
            //{
            return true;
            //}
            //return false;
        }
        #endregion

        #region 民事刑事按钮（显示不同树）
        /// <summary>
        /// 按钮默认颜色全部为白色
        /// </summary>
        public void GetColor()
        {
            button8.BackColor = Color.White;
            button6.BackColor = Color.White;
            button5.BackColor = Color.White;
            button4.BackColor = Color.White;
            button7.BackColor = Color.White;
        }
        /// <summary>
        /// 点击“刑事”，显示刑事树
        /// </summary>
        /// <param name="sender">触发对象</param>
        /// <param name="e">节点</param>
        private void button8_Click(object sender, EventArgs e)
        {
            TypeName = "刑事";
            GetColor();
            Button sendButton = (Button)sender;
            sendButton.BackColor = Color.LightSkyBlue;
            CaseCauseTree();


        }

        /// <summary>
        /// 点击“民事”，显示民事树
        /// </summary>
        /// <param name="sender">触发对象</param>
        /// <param name="e">节点</param>
        private void button6_Click(object sender, EventArgs e)
        {
            TypeName = "民事";
            GetColor();
            Button sendButton = (Button)sender;
            sendButton.BackColor = Color.LightSkyBlue;
            CaseCauseTree();

        }

        /// <summary>
        /// 点击“行政"，显示行政树
        /// </summary>
        /// <param name="sender">触发对象</param>
        /// <param name="e">节点</param>
        private void button5_Click(object sender, EventArgs e)
        {
            TypeName = "行政";
            GetColor();
            Button sendButton = (Button)sender;
            sendButton.BackColor = Color.LightSkyBlue;
            CaseCauseTree();


        }

        /// <summary>
        /// 点击“赔偿"，显示赔偿树
        /// </summary>
        /// <param name="sender">触发对象</param>
        /// <param name="e">节点</param>
        private void button4_Click(object sender, EventArgs e)
        {
            TypeName = "赔偿";
            GetColor();
            Button sendButton = (Button)sender;
            sendButton.BackColor = Color.LightSkyBlue;
            CaseCauseTree();

        }

        /// <summary>
        /// 点击“执行"，显示执行树
        /// </summary>
        /// <param name="sender">触发对象</param>
        /// <param name="e">节点</param>
        private void button7_Click(object sender, EventArgs e)
        {
            TypeName = "执行";
            GetColor();
            Button sendButton = (Button)sender;
            sendButton.BackColor = Color.LightSkyBlue;
            CaseCauseTree();

        }
        #endregion

        #region 编辑案由树节点

        private TreeNode editnode = null; //点击获得当前节点
        /// <summary>
        /// 显示编辑菜单
        /// </summary>
        /// <param name="sender">触发对象</param>
        /// <param name="e">节点</param>
        private void tVCaseCause_MouseDown(object sender, MouseEventArgs e)
        {

            Point ClickPoint = new Point(e.X, e.Y);
            editnode = tVCaseCause.GetNodeAt(ClickPoint);
            if (editnode != null)//判断你点的是不是一个节点
            {
                if (editnode.Level == 0)
                {
                    添加同级ToolStripMenuItem.Visible = false;
                }
                else
                {
                    添加同级ToolStripMenuItem.Visible = true;
                }
                editnode.ContextMenuStrip = contextMenuStrip1;

                Typedt = casecausebLL.GetCaseCauseType();
                NodeTypeList.DataSource = Typedt;
                NodeTypeList.DisplayMember = "CC_NodeTypeName";
                NodeTypeList.ValueMember = "CC_NodeType";

                tVCaseCause.SelectedNode = editnode;  //选中这个节点

            }

        }


        DataTable Typedt = new DataTable();
        private void 添加子节点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            tabControl1.Visible = true;
            tabControl1.SelectTab(tabPage_EditNode);


            NodeFrame.Visible = true;
            EidtNodeGroup.Text = "添加子节点";
            Pname.Text = editnode.Text.ToString();
            label5.Visible = false;
            CC_ID.Visible = false;
            label11.Visible = false;
            CC_ParentID.Visible = false;


            NodeTypeList.SelectedValue = "2";

        }
        private void 添加同级ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            tabControl1.Visible = true;
            tabControl1.SelectTab(tabPage_EditNode);


            NodeFrame.Visible = true;
            EidtNodeGroup.Text = "添加同级节点";
            Pname.Text = editnode.Parent.Text.ToString();
            label5.Visible = false;
            CC_ID.Visible = false;
            label11.Visible = false;
            CC_ParentID.Visible = false;
            NodeTypeList.SelectedValue = "2";
        }
        private void 修改节点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            tabControl1.Visible = true;
            tabControl1.SelectTab(tabPage_EditNode);

            NodeFrame.Visible = true;
            EidtNodeGroup.Text = "修改节点";
            if (editnode.Level == 0)
                Pname.Text = "";
            else Pname.Text = editnode.Parent.Text.ToString();

            DataTable dt = casecausebLL.GetSYS_CaseCauseByCCID(editnode.Tag.ToString());
            label5.Visible = true;
            CC_ID.Visible = true;
            label11.Visible = true;
            CC_ParentID.Visible = true;

            CC_ID.Text = editnode.Tag.ToString();
            Childname.Text = dt.Rows[0]["CC_Name"].ToString();
            CC_ParentID.Text = dt.Rows[0]["CC_ParentID"].ToString();
            try
            {
                if (Convert.ToInt32(dt.Rows[0]["isLeafNode"].ToString()) == 1)
                {
                    isleaf.Checked = true;

                }
                else
                {
                    notleaf.Checked = true;
                }
            }
            catch //(Exception error)
            {
                notleaf.Checked = true;

            }

            // NodeType.Text =;
            NodeTypeList.SelectedValue = dt.Rows[0]["CC_NodeType"].ToString();
        }

        private void 上移ToolStripMenuItem_Click(object sender, EventArgs e)
        {

            string Previd = editnode.PrevNode.Tag.ToString();
            string Nestid = editnode.Tag.ToString();
            casecausebLL.UpCaseCause_SeralNum(Previd, Nestid);
            MovUp(editnode);
        }
        private void 下移ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string Previd = editnode.Tag.ToString();
            string Nestid = editnode.NextNode.Tag.ToString();
            casecausebLL.UpCaseCause_SeralNum(Previd, Nestid);
            MovDown(editnode);
        }
        private void MovUp(TreeNode ObjNode)
        {
            //----节点的向上移动   
            if (ObjNode != null)
            {
                TreeNode newnode = new TreeNode();
                //--------如果选中节点为最顶节点   
                if (ObjNode.Index == 0)
                {
                    //-------------   
                }
                else if (ObjNode.Index != 0)
                {
                    newnode = (TreeNode)ObjNode.Clone();
                    //-------------若选中节点为根节点   
                    if (ObjNode.Level == 0)
                    {
                        tVCaseCause.Nodes.Insert(ObjNode.PrevNode.Index, newnode);
                    }
                    //-------------若选中节点并非根节点   
                    else if (ObjNode.Level != 0)
                    {
                        ObjNode.Parent.Nodes.Insert(ObjNode.PrevNode.Index, newnode);
                    }
                    ObjNode.Remove();
                    ObjNode = newnode;
                }

            }
        }
        private void MovDown(TreeNode ObjNode)
        {
            //----节点的向下移动   
            if (ObjNode != null)
            {
                TreeNode newnode = new TreeNode();
                //-------------如果选中的是根节点   
                if (ObjNode.Level == 0)
                {
                    //---------如果选中节点为最底节点   
                    if (ObjNode.Index == tVCaseCause.Nodes.Count - 1)
                    {
                        //---------------   
                    }
                    //---------如果选中的不是最底的节点   
                    else
                    {
                        newnode = (TreeNode)ObjNode.Clone();
                        tVCaseCause.Nodes.Insert(ObjNode.NextNode.Index + 1, newnode);
                        ObjNode.Remove();
                        ObjNode = newnode;

                    }
                }
                //-------------如果选中节点不是根节点   
                else if (ObjNode.Level != 0)
                {
                    //---------如果选中最底的节点   
                    if (ObjNode.Index == ObjNode.Parent.Nodes.Count - 1)
                    {
                        //-----------   
                    }
                    //---------如果选中的不是最低的节点   
                    else
                    {
                        newnode = (TreeNode)ObjNode.Clone();
                        ObjNode.Parent.Nodes.Insert(ObjNode.NextNode.Index + 1, newnode);
                        ObjNode.Remove();
                        ObjNode = newnode;
                    }
                }

            }
        }

        //保存节点信息
        private void SaveNodeBtn_Click(object sender, EventArgs e)
        {
            try
            {
                SYS_CaseCause model = new SYS_CaseCause();
                if (EidtNodeGroup.Text == "添加子节点")
                {
                    model.CC_ID = newid.JudgeDoc_CreateID("SYS_CaseCause");
                    model.CC_Name = Childname.Text.Replace("\r\n", "");
                    model.CC_ParentID = editnode.Tag.ToString();
                    model.CC_NodeType = Convert.ToInt32(NodeTypeList.SelectedValue);
                    model.isLeafNode = notleaf.Checked == true ? 0 : 1;  //叶子1，非叶子0

                    if (casecausebLL.AddSYS_CaseCause(model,Gvar.uo.m_loginName))
                    {
                        casecausebLL.CaseCauseUpdateAllPid(model.CC_ID);
                        MessageBox.Show("节点保存成功！");
                        editnode.Expand();
                        TreeNode addnode = new TreeNode();
                        addnode.Tag = model.CC_ID;
                        addnode.Text = model.CC_Name;
                        addnode.Name = model.CC_NodeType.ToString();
                        editnode.Nodes.Add(addnode);

                    }
                }
                else if (EidtNodeGroup.Text == "添加同级节点")
                {
                    model.CC_ID = newid.JudgeDoc_CreateID("SYS_CaseCause");
                    model.CC_Name = Childname.Text.Replace("\r\n", "");
                    model.CC_ParentID = editnode.Parent.Tag.ToString();
                    model.CC_NodeType = Convert.ToInt32(NodeTypeList.SelectedValue);
                    model.isLeafNode = notleaf.Checked == true ? 0 : 1;  //叶子1，非叶子0

                    if (casecausebLL.AddSYS_CaseCause(model,Gvar.uo.m_loginName))
                    {
                        casecausebLL.CaseCauseUpdateAllPid(model.CC_ID);
                        MessageBox.Show("节点保存成功！");
                        editnode.Parent.Expand();
                        TreeNode addnode = new TreeNode();
                        addnode.Tag = model.CC_ID;
                        addnode.Text = model.CC_Name;
                        addnode.Name = model.CC_NodeType.ToString();
                        editnode.Parent.Nodes.Add(addnode);
                    }
                }
                else  //编辑
                {
                    model.CC_ID = editnode.Tag.ToString();
                    model.CC_Name = Childname.Text.Replace("\r\n", "");
                    model.CC_ParentID = CC_ParentID.Text.Trim();
                    model.CC_NodeType = Convert.ToInt32(NodeTypeList.SelectedValue);
                    model.isLeafNode = notleaf.Checked == true ? 0 : 1;  //叶子1，非叶子0

                    if (casecausebLL.AddSYS_CaseCause(model, Gvar.uo.m_loginName))
                    {
                        casecausebLL.CaseCauseUpdateAllPid(model.CC_ID);
                        MessageBox.Show("节点编辑成功！");
                        editnode.Text = model.CC_Name;
                        editnode.Name = model.CC_NodeType.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MsgBox.Err(@"节点保存失败！");
                Log.ErrorLog(ex.Message);
            }
            ClearGroupEditNode();

            NodeFrame.Visible = false;
        }
        //清空节点信息框
        public void ClearGroupEditNode()
        {
            label5.Visible = false;
            CC_ID.Visible = false;
            EidtNodeGroup.Text = "";
            Pname.Text = "";
            Childname.Text = "";
            notleaf.Checked = true;
            NodeTypeList.SelectedValue = "2";
        }
        //取消编辑节点
        private void button3_Click(object sender, EventArgs e)
        {

            NodeFrame.Visible = false;
            ClearGroupEditNode();
        }


        #region 查询节点
        DataTable Querydt;
        private void QueryNodeTxt_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                QueryNode();
            }
        }

        private void QueryNode()
        {
            string QueryNodeName = QueryNodeTxt.Text.Trim();

            if (QueryNodeName != "")
            {
                Querydt = trbll.NodeTree_Query(FirId, QueryNodeName, 1);
                StacticQuery.Text = Querydt.Rows.Count.ToString();
                if (Querydt.Rows.Count > 0)
                {
                    CurrNodeNum.Text = "1";
                    SumQuery.Text = CurrNodeNum.Text;
                    int CurrNode = Convert.ToInt32(CurrNodeNum.Text);
                    LinkIsVisible(CurrNode);
                    QueryNode_Page(Querydt, CurrNode);
                }
                else
                {
                    CurrNodeNum.Text = "0";
                    SumQuery.Text = CurrNodeNum.Text;
                    MessageBox.Show("没有查询到结果！");
                }
            }
            else
            {
                MessageBox.Show("请输入关键字！");
            }
        }
        private void QueryNodeBtn_Click(object sender, EventArgs e)//查询
        {
            QueryNode();
        }
        ///// <summary>
        ///// 下一条
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void Nextlinkbtn_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        //{
        //    CurrNodeNum.Text = (Convert.ToInt32(CurrNodeNum.Text) + 1).ToString();
        //    SumQuery.Text = CurrNodeNum.Text;
        //    int CurrNode = Convert.ToInt32(CurrNodeNum.Text);
        //    QueryNode_Page(Querydt, CurrNode);
        //    LinkIsVisible(CurrNode);
        //}
        ///// <summary>
        ///// 上一条
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void Prelinkbtn_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        //{
        //    CurrNodeNum.Text = (Convert.ToInt32(CurrNodeNum.Text) - 1).ToString();
        //    SumQuery.Text = CurrNodeNum.Text;
        //    int CurrNode = Convert.ToInt32(CurrNodeNum.Text);
        //    QueryNode_Page(Querydt, CurrNode);
        //    LinkIsVisible(CurrNode);
        //}
        /// <summary>
        /// 查询分页
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="showindex"></param>
        private void QueryNode_Page(DataTable dt, int showindex)
        {
            if (dt.Rows.Count >= showindex)
            {
                string[] NotePidArr = trbll.GetAllParentNode(dt.Rows[showindex - 1]["id"].ToString()).Split(',');
                for (int i = 0; i < NotePidArr.Length; i++)
                {
                    if (i != NotePidArr.Length - 1)
                    {
                        FindNode(NotePidArr[i]).Expand();
                    }
                    else
                    {
                        TreeNode node = FindNode(NotePidArr[i]);
                        this.tVCaseCause.SelectedNode = node;
                    }
                }
            }
            else
            {
                MessageBox.Show("跳转页码有误，重新输入！");
            }
        }
        /// <summary>
        /// 找到节点
        /// </summary>
        /// <param name="Nodeid"></param>
        /// <returns></returns>
        private TreeNode FindNode(string Nodeid)
        {
            foreach (TreeNode node in NodeList)
            {
                if (node.Tag.ToString() == Nodeid)
                {
                    return node;
                }
            }
            return null;

        }
        /// <summary>
        /// 上一条下一条是否可用
        /// </summary>
        /// <param name="CurrNode"></param>
        private void LinkIsVisible(int CurrNode)
        {
            Prelinkbtn.Enabled = true;
            Nextlinkbtn.Enabled = true;
            if (CurrNode <= 1)
            {
                Prelinkbtn.Enabled = false;
            }
            if (CurrNode >= Querydt.Rows.Count)
            {
                Nextlinkbtn.Enabled = false;
            }

        }
        ///// <summary>
        ///// 跳页查询
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void GoQuery_Click(object sender, EventArgs e)
        //{
        //    int CurrNode = Convert.ToInt32(SumQuery.Text);

        //    if (Querydt.Rows.Count >= CurrNode)
        //    {
        //        CurrNodeNum.Text = SumQuery.Text;
        //        QueryNode_Page(Querydt, CurrNode);
        //        LinkIsVisible(CurrNode);
        //    }
        //    else
        //    {
        //        MessageBox.Show("跳转页码有误，重新输入！");
        //    }

        //}

        #endregion

        #endregion

        #endregion

        #region 右侧



        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (tabControl1.SelectedTab.Name)
            {

                case "Tab_RelLaw":
                    ShowTab_RelLaw();
                    break;
            }

        }

        private void ShowTab_RelLaw()
        {
            ShowRelationLaw(clicknode.Tag.ToString());  //显示相关法规
        }




        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="e"></param>
        public void GetRightValue(TreeViewEventArgs e)
        {
            ShowTab_RelLaw();

        }


        /// <summary>
        /// 清空当前节点
        /// </summary>
        public void ClearRightValue(TreeViewEventArgs e)
        {
            clicknode = null;

        }


        #region 相关法条（第三个插页）
        /// <summary>
        /// 显示来源列表
        /// </summary>
        /// <param name="CC_ID"></param>
        private void ShowRelationLaw(string CC_ID)
        {
            DV_QuoteLawRel.AutoGenerateColumns = false;
            DV_QuoteLawRel.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            ProvText.Text = "";
            DV_QuoteLawReldataPager1.ChangePageNumber(1);
        }

        private void btn_relaProv_Click(object sender, EventArgs e)
        {
            DV_QuoteLawReldataPager1.ChangePageNumber(1);
        }
        public void Dataflash()
        {
            DV_QuoteLawReldataPager1.ChangePageNumber(1);
        }

        private void DV_QuoteLawReldataPager1_PageNumberChanging(object sender, Controls.DataPagerPageIndexChangingEventArgs e)
        {
            if (clicknode != null)
            {

                var startRowIndex = e.StartRowIndex;
                //var maximumRows = e.MaximumRows;
                var endRowIndex = e.StartRowIndex + e.MaximumRows;
                DataTable dt = quoteLawRelBLL.QuoteLawRelGetList(clicknode.Tag.ToString());
                DV_QuoteLawRel.DataSource = dt;

                if (dt.Rows.Count > 0)
                {
                    e.TotalCount = dt.Rows.Count;
                    DataTable newdt = new DataTable();
                    newdt = dt.Clone();
                    DataRow[] dr = dt.Select("showindex>" + startRowIndex + " and showindex<=" + endRowIndex);
                    for (int i = 0; i < dr.Length; i++)
                    {
                        newdt.ImportRow((DataRow)dr[i]);
                    }

                    DV_QuoteLawRel.DataSource = newdt;
                }
                else
                {
                    DV_QuoteLawRel.DataSource = new DataTable();
                }
            }

        }


        private void DV_QuoteLawRel_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                string OLR_Law_ProvID = DV_QuoteLawRel.Rows[e.RowIndex].Cells["OLR_Law_ProvID"].Value.ToString();
                ProvText.Text = quoteLawRelBLL.GetProvText(OLR_Law_ProvID);
            }

        }
        /// <summary>
        /// 弹出页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RelLaw_Case_Click(object sender, EventArgs e)
        {
            NodeTree_Case quoteLawRelAboutCase = new NodeTree_Case();

            quoteLawRelAboutCase.stiuationId = clicknode.Tag.ToString();  // clicknode.Tag.ToString()
            quoteLawRelAboutCase.stiuationName = clicknode.Text.ToString();
            quoteLawRelAboutCase.stiuationType = clicknode.Name.ToString();
            if (clicknode.Parent != null)
                quoteLawRelAboutCase.pid = clicknode.Parent.Tag.ToString();
            else quoteLawRelAboutCase.pid = "";
            quoteLawRelAboutCase.Show();



        }


        private void DeleteProv_Click(object sender, EventArgs e)
        {

        }




        #endregion

        private void 删除ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确认要删除节点" + editnode.Text.ToString() + "及其子节点吗？", "此删除不可恢复", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    casecausebLL.DeleteSYS_CaseCause(editnode.Tag.ToString(), editnode.Text.ToString(), Gvar.uo.m_loginName);
                    MessageBox.Show("删除成功!");
                    tVCaseCause.Nodes.Remove(editnode);

                }
                catch //(Exception error)
                {
                    MessageBox.Show("删除失败!");
                }

            }

        }
        #endregion












    }

}